package com.jfm.jfmc.plugin.icmp.utils;

import java.io.IOException;
import java.net.InetAddress;

/**
 * @author DYang
 * @since 2024-10-11 22:30
 */
public class ICMPUtil {

    /**
     * 判断主机是否可用
     * @param host
     * @param timeout
     * @return
     */
    public static boolean isValidHost(String host, long timeout){
        try {
            return InetAddress.getByName(host).isReachable((int) timeout);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
